package com.base.service.impl;

import com.base.mapper.voipmapper.NoviceClassMapper;
import com.base.po.novice.NoviceClass;
import com.base.service.NoviceClazzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class NoviceClazzServiceImpl implements NoviceClazzService {

    @Autowired
    private NoviceClassMapper noviceClassMapper;


    @Override
    public List<NoviceClass> findAllNoviceClass(String ncParent, int ncDatastatus) {
        return noviceClassMapper.findAllNoviceClass(ncParent,ncDatastatus);
    }

    @Override
    public NoviceClass findNoviceClassById(String ncId) {
        return noviceClassMapper.selectByPrimaryKey(ncId);
    }

    @Override
    @Transactional
    public int updateNoviceClassByNcId(NoviceClass noviceClass) {
        return noviceClassMapper.updateByPrimaryKey(noviceClass);
    }

    @Override
    @Transactional
    public int updateNoviceClassByNcParent(NoviceClass noviceClass) {
        return noviceClassMapper.updateByParentId(noviceClass);
    }

    @Override
    @Transactional
    public int insertNoviceClassByNcParent(NoviceClass noviceClass) {
        return noviceClassMapper.insert(noviceClass);
    }

    @Override
    @Transactional
    public boolean deleteNoviceClassById(String ncId) {
        return noviceClassMapper.deleteNoviceClassById(ncId);
    }


    /**
     * 查询出所有新手指南信息
     * @return
     */
    @Override
    public List<NoviceClass> findAllNoviceClassInfo(Integer start,Integer num) {
        return noviceClassMapper.findAllNoviceClassInfo(start,num);
    }

    @Override
    @Transactional
    public boolean deleteNoviceClassByParentId(String parentId) {
        return noviceClassMapper.deleteNoviceClassByParentId(parentId);
    }

    @Override
    @Transactional
    public boolean updateNoviceDataStatusById(String ncId, int ncDatastatus) {
        return noviceClassMapper.updateNoviceDataStatusById(ncId,ncDatastatus);
    }

    @Override
    public List<NoviceClass> adminFindAllInfo() {
        return noviceClassMapper.adminFindAllInfo();
    }

    @Override
    public boolean adminIudgeNoviceInfo(NoviceClass noviceClass) {
        return noviceClassMapper.adminIudgeNoviceInfo(noviceClass).size() > 0;
    }
}
